/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 *
 *MmsMarketingProductlineInfoController
 * 省区行销产品线配置信息表新
 *
 * 修改纪录
 * 2021-07-08 版本：1.0 lvzhijun 创建。
 * @version 版本：1.0
 * @author 作者：lvzhijun
 * 创建日期：2021-07-08
 */

package com.topscomm.mms.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.topscomm.mms.service.impl.MmsProvinceMarketingInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.topscomm.mms.controller.auto.MmsMarketingProductlineInfoControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: lvzhijun
 * @date: 2021-07-08
 * @description:省区行销产品线配置信息表新Controller
 * @modify:
 */
@RestController
@RequestMapping("mms/marketingProductlineInfo")
public class MmsMarketingProductlineInfoController extends MmsMarketingProductlineInfoControllerAuto implements IMmsMarketingProductlineInfoController {
	@Autowired
	private MmsProvinceMarketingInfoService mmsProvinceMarketingInfoService;
	/**
	 * @author: lvzhijun
	 * @date: 2021-07-08
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_name")) {
			String value = paraMap.get("qry_name").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and name like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_code")) {
			String value = paraMap.get("qry_code").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and code = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: lvzhijun
	 * @date: 2021-07-08
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}

	/**
	 * @description: 获取行销产品页面所需数据
	 * @param paraMap
	 * @return com.topscomm.pub.vo.ResponseResult<java.lang.Object>
	 * @author: wangxinhua
	 * @date: 2021/8/2 19:51
	 * @modify:
	 */
	@GetMapping(value="/getMarketingInfo")
	public ResponseResult<Object> getMarketingInfo(@RequestParam(required = false) Map<String, Object> paraMap) {
		//获取行销对应产品线数据
		Map<String, Object> resMap = this.service.getMarketingProductInfos(paraMap);
		return ResponseResult.ok(resMap);
	}

	@PostMapping(value="/saveMarketingInfo")
	public ResponseResult<Object> saveMarketingInfo(@RequestBody(required = false) Map<String, Object> paraMap) {
		List<Map<String, Object>> tableData = (List<Map<String, Object>>) paraMap.get("tabledata");
		paraMap.remove("tabledata");
		this.service.saveMarketingProductInfos(tableData, paraMap);
		return ResponseResult.ok("保存成功");
	}
}

